<%@page import="auxilary.Links"%>
<%@page import="java.util.List"%>
<%@page import="auxilary.Actions"%>
<%@page import="entities.User"%>
<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<%
	List<User> users = (List<User>) request.getAttribute("users");
	User user = (User) request.getSession().getAttribute("user");
	boolean loggedIn = (user != null);
	boolean isAdmin = (loggedIn) ? user.isAdmin() : false;
%>
<jsp:include page="/frames/start.jsp" />
	<%=Links.Css.USER %>
	<%=Links.Scripts.USER %>
<jsp:include page="/frames/frame.jsp" />
			<h1>All Users</h1>
			<br />
		   <% if (users.isEmpty()) { %>
		    <center><h3>There are no users</h3></center>
		   <% } else {%>
			<table>
				<tr>
					<th class="username">Username</th>
					<th class="name">Name</th>
					<th class="email">E-mail</th>
					<th class="faculty">Faculty</th>
					<th class="semester">S</th>
					<th class="phone">Phone</th>
				   <% if (isAdmin) { %>
					<th>courses</th>
				   <% } %>
				</tr>
			   <% for (User listUser : users) { %>
				<tr>
					<td class="username"><%=listUser.getUsername() %></td>
					<td class="name"><%=listUser.getFirstName() %> <%=listUser.getLastName() %></td>
					<td class="email"><%=listUser.getEmail() %></td>
					<td class="faculty"><%=listUser.getFaculty() %></td>
					<td class="semester"><%=listUser.getSemester() %></td>
					<td class="phone"><%=listUser.getPhone() %></td>
				   <% if (isAdmin) { %>
					<td class="courses info" onclick="window.location.href='<%=Links.Pages.USERS_BASE %><%=listUser.getId() %>'">view user info</td>
					<td class="x" onclick="deleteUserByUsername(<%=Actions.User.DELETE %>,'<%=listUser.getUsername() %>')"><img src="http://www.clker.com/cliparts/6/b/c/4/1194985626525719339tasto_11_architetto_fran_01.svg.med.png" /></td>
				   <% } %>
				</tr>
			   <% } %>
			</table>
		   <% } %>
<jsp:include page="/frames/end.jsp" />